﻿#ifndef JZWEB_WIDGET_H_
#define JZWEB_WIDGET_H_

#include <QObject>
#include <QDomDocument>
#include "JZWebLayout.h"
#include "JZWebContext.h"

class JZWebWidgetPage;
class JZWebWidget : public QObject
{
	Q_OBJECT

public:
	JZWebWidget(JZWebWidgetPage *page);
	virtual ~JZWebWidget();
	
	int id();

	void setLayout(JZWebLayout *l);
	JZWebLayout *layout();
	
	virtual QDomElement render(QDomDocument& doc);

	void setValue(int prop, const QVariant& v);
	QVariant getValue(int prop);

protected:
	JZWebContext* context();

	int m_id;
	JZWebLayout* m_layout;
	JZWebWidgetPage* m_page;
};

class JZWebWidgetRoot : public JZWebWidget
{
	Q_OBJECT

public:
	JZWebWidgetRoot(JZWebWidgetPage *page);
	virtual ~JZWebWidgetRoot();

	virtual QDomElement render(QDomDocument& doc);

protected:

};

class JZWebLabel : public JZWebWidget
{
	Q_OBJECT

public:
	JZWebLabel(JZWebWidgetPage* page);
	~JZWebLabel();

	virtual QDomElement render(QDomDocument& doc);

	QString text();
	void setText(QString text);

protected:

};

class JZWebLineEdit : public JZWebWidget
{
	Q_OBJECT

public:
	JZWebLineEdit(JZWebWidgetPage* page);
	~JZWebLineEdit();

	virtual QDomElement render(QDomDocument& doc);

	QString text();
	void setText(QString text);
};


class JZWebTextBox : public JZWebWidget
{
	Q_OBJECT

public:
	JZWebTextBox(JZWebWidgetPage* page);
	~JZWebTextBox();

	virtual QDomElement render(QDomDocument& doc);

	QString text();
	void setText(QString text);
	void append(QString text);
};

class JZWebComboBox : public JZWebWidget
{
	Q_OBJECT

public:
	JZWebComboBox(JZWebWidgetPage* page);
	~JZWebComboBox();

	void addItem(QString text);

signals:
	void sigCurrentIndexChanged(int index);

protected:
	QStringList m_items;
};

class JZWebCheckBox : public JZWebWidget
{
	Q_OBJECT

public:
	JZWebCheckBox(JZWebWidgetPage* page);
	~JZWebCheckBox();

signals:
	void sigCilcked();

protected:

};

class JZWebRadioButton : public JZWebWidget
{
	Q_OBJECT

public:
	JZWebRadioButton(JZWebWidgetPage* page);
	~JZWebRadioButton();

signals:
	void sigCilcked();

protected:

};

class JZWebPushButton : public JZWebWidget
{
	Q_OBJECT

public:
	JZWebPushButton(JZWebWidgetPage* page);
	~JZWebPushButton();

signals:
	void sigCilcked();

protected:

};

#endif // !JZWEB_WIDGET_H_
